package com.sh.d1.gatewayserver;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public final  class NettyClientGroup {

    /**
     * netty 客户端
     * key = serverId  val = nettyClient
     */
    static private final Map<String, NettyClient>  _nettyClientMap=new ConcurrentHashMap<>();


    private NettyClientGroup(){}


    /**
     * 根据serverId 获取nettyClient
     * @param serverId
     * @return
     */
    static public NettyClient getByServerId(String serverId){
        return _nettyClientMap.get(serverId);
    }

    /**
     *  依据serverId 添加nettyClient
     * @param serverId
     * @param nettyClient
     */
    static public void add(String serverId,NettyClient nettyClient){
        if(null==serverId || null == nettyClient){
            return;
        }
        _nettyClientMap.put(serverId,nettyClient);

    }

    static public void removeByServerId(String serverId){
        _nettyClientMap.remove(serverId);
    }
}
